package main

import (
	"context"
	"fmt"
	"github.com/google/generative-ai-go/genai"
	"google.golang.org/api/option"
	"log"
)

func main() {
	ctx := context.Background()
	// Access your API key as an environment variable (see "Set up your API key" above)
	//client, err := genai.NewClient(ctx, option.WithAPIKey("AIzaSyATcpDYCN05jyjuITrQrHZOM6wxNyB_yjE"))
	client, err := genai.NewClient(ctx, option.WithAPIKey("AIzaSyD4XE0hlnz3FI3tk0KOm3j1RKacrLHtT7I"))
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()
	// For text-only input, use the gemini-pro model
	model := client.GenerativeModel("gemini-pro")
	//resp, err := model.GenerateContent(ctx, genai.Text("翻译'白纸的背景颜色突出显示了他胖胖的身体'"))
	content := "一个女子，美女，长发，仙气飘飘，神女，白色花朵，桃花树下，手上拿着竖琴，优雅地站着，黑发，粉色汉服 ，古装，金色的花纹，闪闪发光，金光闪闪，精致的手，夜晚，上弦月下，古色古香的阁楼，水彩渲染长安城，古代，大场景云海，广阔的视野，高角度试图，柔和的月光，闪烁的星云，电影照明，8K,详细，数字插画，白紫劫雷"
	//content := "A maiden with ethereal beauty, flowing hair, and a divine aura stands gracefully beneath a blossoming peach tree, holding a lyre in her hands. Clad in a flowing pink Hanfu adorned with intricate gold embroidery, her black hair cascades over her shoulders like a silken waterfall. The soft moonlight of a crescent moon illuminates the ancient pavilion and the enchanting长安city, rendered in soft watercolor hues. The vast expanse of clouds and mountains stretches out before her in a breathtaking panorama, creating a cinematic and ethereal ambiance. The sparkling effects of stars and golden lightning add an element of celestial magic, while the soft, radiant glow of the moon casts a delicate and ethereal glow upon the scene, creating an image of breathtaking beauty and grandeur."
	//resp, err := model.GenerateContent(ctx, genai.Text(fmt.Sprintf("翻译'%s'", content)))
	//resp, err := model.GenerateContent(ctx, genai.Text(fmt.Sprintf("翻译为中文'%s'", content)))
	resp, err := model.GenerateContent(ctx, genai.Text(fmt.Sprintf("翻译为英文'%s'", content)))
	//resp, err := model.GenerateContent(ctx, genai.Text(fmt.Sprintf("你好")))
	//resp, err := model.GenerateContent(ctx, genai.Text("翻译'The white background emphasized his corpulent frame'"))
	if err != nil {
		log.Fatal(err)
	}
	printResponse(resp)
	////fmt.Println(resp.Candidates[0].Content.Parts[0])
	//fmt.Println(resp.Candidates)

	//model := client.GenerativeModel("gemini-1.5-pro-latest")
	//model.SetTemperature(0.9)
	//model.SetTopP(0.5)
	//model.SetTopK(20)
	//model.SetMaxOutputTokens(10000)
	//model.SystemInstruction = &genai.Content{
	//	Parts: []genai.Part{genai.Text("你是一个翻译家，精通中英文互译，直接翻译输入的内容")},
	//}
	////model.ResponseMIMEType = "application/json"
	////resp, err := model.GenerateContent(ctx, genai.Text("你好"))
	////content := "一个女子，美女，长发，仙气飘飘，神女，白色花朵，桃花树下，手上拿着竖琴，优雅地站着，黑发，粉色汉服 ，古装，金色的花纹，闪闪发光，金光闪闪，精致的手，夜晚，上弦月下，古色古香的阁楼，水彩渲染长安城，古代，大场景云海，广阔的视野，高角度试图，柔和的月光，闪烁的星云，电影照明，8K,详细，数字插画，白紫劫雷"
	//content := "A beautiful woman with long, flowing black hair stands gracefully beneath a peach blossom tree. Her ethereal presence radiates a goddess-like aura. She is adorned in a pink Hanfu, a traditional Chinese garment, embellished wi\nth shimmering gold patterns that gleam under the soft moonlight. In her delicate hands, she holds a harp. The scene is set at night, under a crescent moon, with a traditional Chinese-style pavilion in the background. Watercol\nor washes depict the ancient city of Chang'an, while a vast sea of clouds stretches out beyond, creating a breathtaking panorama. The high-angle perspective emphasizes the grandeur of the scene. Sparkling nebulae dot the nigh\nt sky, illuminated by cinematic lighting that enhances the 8K resolution of this detailed digital illustration. The presence of white and purple lightning adds a dramatic touch, hinting at the \"White Purple Tribulation Lightn\ning\""
	//resp, err := model.GenerateContent(ctx, genai.Text(content))
	//if err != nil {
	//	log.Fatal(err)
	//}

}
func printResponse(resp *genai.GenerateContentResponse) {
	for _, cand := range resp.Candidates {
		if cand.Content != nil {
			for _, part := range cand.Content.Parts {
				fmt.Println(part)
			}
		}
	}
}
